<?php $this->load->module('mobile/index/header', $common);?>

<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/main.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/dialog.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/base.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/index.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/line.css" />
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/mobilecommon.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/slider.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/dialog.js"></script>
<style>
    .w-item{

        background: #fff;

    }
.conlist{
    background-color: #349cd1;
    color: #fff;
}
    .fontorange, .font-orange {
    color: #349cd1;
}
    .b1{
        font-size: 1.5rem;
        color: #e55927;
    font-weight:bold}
    .btnle{
        width: 60%;
        height: 2rem;
        background-color: #349cd1;
        border-radius: 5px;
        color: #ffffff;
        font-size: 1rem;
        font-weight: bold;
        line-height: 2rem;
        display:block;
        text-align: center;margin:0 20%;
        margin-top: 0.5rem; }
    .col_div {
        margin-top: 1.78em;
        background: #f2f2f2;
        padding: 10px;
        border-top: 9px solid #c8c9ca;
    }
    .mt_span{padding-bottom:0}
</style>
<div class="container">
    <div class="w-item conlist">
        <dl class="fn-clear">
            <dt>门票：</dt>
            <dd id="sName"><?php echo $scenic['name']?></dd>
        </dl>
        <dl class="fn-clear">
            <dt>￥<?php echo $ticket['price_list'][0]['price']?></dt>
        </dl>
        <dl class="fn-clear">
            <dt>说明：</dt>
            <dd id="sDes">
                <?php if(!empty($ticket['notes'])){?>
                <?php echo nl2br($ticket['notes']);?>
                <?php }?></dd>
        </dl>
    </div>
    <div class="w-item">
        <dl class="in-item fn-clear">
            <dt>日期</dt>

            <dd>
                <span class="writeok">
                <select name="date" id="goDate" class="fontorange">
                    <option value="0">请选择团期</option>
                    <?php foreach($ticket['price_list'] as $k=>$v):?>
                        <option value="<?php echo $v['date'];?>"><?php echo $v['date'];?></option>
                    <?php endforeach ; ?>
                </select>
                </span>
            </dd>

        </dl>
    </div>

    <div class="w-item" style="
        border-top: 1px solid #c8c9ca;">
        <dl class="in-item-number fn-clear">
            <dt>数量</dt>
            <dd> <span class="btn min_order" id="min_order"></span>
                <input type="tel" class="ipt-numbers notice" maxlength="3"  value="1" id="input_num" name="num" readonly="readonly">
                <span  class="btn plus_order" id="plus_order"></span> </dd>
        </dl>
    </div>

    <div class="w-item" style="
        border-top: 1px solid #c8c9ca;border-width: 9px;">
        <dl class="in-item fn-clear">
            <dt>取票人</dt>
            <dd>
                <input type="text" name="name" placeholder="请填写取票人姓名" value="" class="writeok">
            </dd>
        </dl>
    </div>
    <div class="w-item marginTop" style="
        border-top: 1px solid #c8c9ca;">
        <dl class="in-item fn-clear borderTop">
            <dt>手机号</dt>
            <dd>
                <input type="tel" name="phone" maxlength="11" placeholder="请填写取票人手机号码" value="" class="writeok">
            </dd>
        </dl>
    </div>
    <p class="font-orange mt_span list-item ">如需预订，您最晚要在游玩<?php
        echo !empty($ticket['earlier_date']) ? "前".$ticket['earlier_date']."天，" : '当天';
        echo !empty($ticket['earlier_time']) ? $ticket['earlier_time'] : '00:00';
        ?>之前下单，请尽早预订。</p>
</div>
<div class="col_div">
    <div style="text-align:center">
        <span class="font-orange " style="display:none;" >¥<span id="price"><?php echo @intval($ticket['price_list'][0]['price']);?></span></span> <span style="display:none;"  id="head_num" class="font-orange">1</span>


        订单总额： <span class="font-orange b1">¥</span><span class="b1 current_price font-orange"><?php echo $ticket['price_list'][0]['price'];?></span></div>
    <a class="btnle btn_submit" href="javascript:void(0);" title="提交订单">提交订单</a>
</div>
<input type="hidden" name="ticket_id" value="<?php echo $ticket['id']?>" />
<input type="hidden" name="scenic_id" value="<?php echo $ticket['scenic']?>" />
</form>

<?php $this->load->module('mobile/index/footer', $common);?>
<script type="text/javascript">
    function alert_popup(text){
        $.dialog({
            style:'tip',
            width:200,
            closeTime:1000,
            content: '<p style="text-align: center">'+text+'</p>'
        }).open();
    }


    $(function(){
        var storeNum = 1;
        var price = parseFloat($('#price').text());
        $('#min_order').click(function(){

            var input_num = $('#input_num');
            if(input_num.val() === ''){
                return;
            }
            var num = parseInt(input_num.val());
            if(num>1){
                input_num.val(--num);
                $('.current_price').text(price*num);
                $('#head_num').empty().text(num);
            }
            storeNum = num;
        });
        $('#plus_order').click(function(){
            var input_num = $('#input_num');
            if(input_num.val() === ''){
                return;
            }
            var num = parseInt(input_num.val());
            input_num.val(++num);
            $('.current_price').text(price*num);
            $('#head_num').empty().text(num);
            storeNum = num;
        });

        var slid = $("#sliderimg").slider({
            loop: true
        });

        $('.btn_submit').click(function(){
            if($('select[name="date"]').val()== '0'){
                alert_popup('请选择日期');
                return false;
            }
            if($('input[name="name"]').val().length == 0){
                alert_popup('请输入姓名');
                return false;
            }
            if($('input[name="phone"]').val().length == 0){
                alert_popup('请输入手机号');
                return false;
            }else {
                var $val = $("input[name='phone']").val();
                var length = $val.length;
                var status = (length == 11 && /^(((17[0-9]{1})|(13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/.test($val));
                if(status==false){
                    alert_popup('请正确填写您的手机号码');
                    return false;
                }
            }
            var ticket_id = $('input[name="ticket_id"]').val();
            var scenic_id = $('input[name="scenic_id"]').val();
            var date = $('select[name="date"]').val();
            var num  = $('#input_num').val();
            var name  = $('input[name="name"]').val();
            var phone  = $('input[name="phone"]').val();
            $.post('<?php echo $form_url ;?>',{
                ticket_id: ticket_id,
                scenic_id: scenic_id,
                date: date,
                num: num,
                name: name,
                phone: phone,
                debug:'<?php echo DEBUG ? 'zlb' : ''?>'
            },function(data){
                alert_popup(data.info);
                if(data.status=='1')
                {
                    setTimeout(function(){
                        window.location.href='<?php echo site_url('mobile/member/center') ?>';
                    }, 1200);
                }
            },'json')
        })


    });
</script>